<?php

namespace App\Http\Controllers\Home;

use App\Models\Cates;

use App\Models\Goods;
use Illuminate\Http\Request;

use App\Http\Controllers\Admin\CatesController;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;

class IndexController extends Controller
{
    public function getIndex()
    {
        $new = DB::table('goods')->skip(0)->take(6)->orderBy('created_at','desc')->get();

        $sale = DB::table('goods')->skip(0)->take(3)->orderBy('sale_num','desc')->get();

        $best = DB::table('goods')->skip(0)->take(4)->where('is_best',1)->orderBy('created_at','desc')->get();

        $hot = DB::table('goods')->skip(0)->take(3)->orderBy('visit_num','desc')->get();

        $cates = CatesController::getCatesByPid(0);
        return view('Home/Index/index', ['cates'=>$cates, 'hot'=>$hot, 'new'=>$new, 'sale'=>$sale, 'best'=>$best]);
    }


}
